import MainLayout from '@/layouts/MainLayout.vue'
import type { RouteRecordRaw } from 'vue-router'

// 动态菜单路由表
export const asyncRoutes: RouteRecordRaw[] = [
  // 园区管理
  {
    path: '/park',
    name: 'park',
    component: MainLayout,
    meta: {
      title: '园区管理',
      icon: 'park',
      permission: 'park',
    },
    children: [
      {
        path: 'building',
        name: 'building',
        meta: { title: '楼宇管理', permission: 'park:building' },
        component: () => import('@/views/park/ParkBuilding.vue'),
      },
      {
        path: 'enterprise',
        name: 'enterprise',
        meta: { title: '企业管理', permission: 'park:enterprise' },
        component: () => import('@/views/park/ParkEnterprise.vue'),
      },
    ],
  },
  // 行车管理
  {
    path: '/parking',
    name: 'parking',
    component: MainLayout,
    meta: { title: '行车管理', icon: 'car', permission: 'parking' },
    children: [
      {
        path: 'area',
        name: 'area',
        component: () => import('@/views/car/CarArea.vue'),
        meta: { title: '区域管理', permission: 'parking:area' },
      },
      {
        path: 'card',
        name: 'card',
        component: () => import('@/views/car/CarCard.vue'),
        meta: { title: '月卡管理', permission: 'parking:card' },
      },
      {
        path: 'pay',
        name: 'pay',
        component: () => import('@/views/car/CarPay.vue'),
        meta: { title: '停车缴费管理', permission: 'parking:payment' },
      },
      {
        path: 'rule',
        name: 'rule',
        component: () => import('@/views/car/CarRule.vue'),
        meta: { title: '计费规则管理', permission: 'parking:rule' },
      },
    ],
  },
  // 物业费管理
  {
    path: '/propety',
    name: 'propety',
    component: MainLayout,
    meta: { permission: "property", title: "物业费管理", icon: "property" },
    children: [
      {
        path: 'cost',
        name: 'cost',
        component: () => import('@/views/property/PropertyPage.vue'),
        meta: { title: '物业费管理', icon: 'property', permission: "property:propertyFee", },
      },
    ],
  },
  // 一体杆管理
  {
    path: '/pole',
    name: 'pole',
    component: MainLayout,
    meta: {
      title: '一体杆管理',
      icon: 'rod',
      permission: 'pole',
    },
    children: [
      {
        path: 'info',
        name: 'info',
        component: () => import('@/views/rod/RodManage.vue'),
        meta: { title: '一体杆管理', permission: 'pole:info' },
      },
      {
        path: 'waring',
        name: 'waring',
        component: () => import('@/views/rod/RodWarn.vue'),
        meta: { title: '告警记录', permission: 'pole:warning' },
      },
    ],
  },
  // 系统管理
  {
    path: '/sys',
    name: 'sys',
    component: MainLayout,
    meta: { title: '系统管理', icon: 'system', permission: 'sys' },
    children: [
      {
        path: 'role',
        name: 'role',
        component: () => import('@/views/system/SystemRole.vue'),
        meta: { title: '角色管理', permission: 'sys:role' },
      },
      {
        path: 'user',
        name: 'user',
        component: () => import('@/views/system/SystemEmployee.vue'),
        meta: { title: '员工管理', permission: 'sys:user' },
      },
    ],
  },
]

// 动态功能页路由表
export const asyncFeaturesRoutes: RouteRecordRaw[] = [
  // 添加编辑系统角色
  {
    path: '/addRole/:id?',
    name: 'addRole',
    component: () => import('@/views/system/AddSystemRole.vue'),
    meta: { hidden: true, permissionFeatures: 'sys:role:add_edit' }
  },
  // 查看警告详情
  {
    path: '/warnDetail/:id',
    name: 'warnDetail',
    component: () => import('@/views/rod/RodWarnDetail.vue'),
    meta: { hidden: true, permissionFeatures: 'pole:warning:query' }
  },
  // 查看企业页
  {
    path: '/exterpriseDetail/:id?',
    name: 'exterpriseDetail',
    component: () => import('@/views/park/EnterpriseDetail.vue'),
    meta: { hidden: true, permissionFeatures: 'park:enterprise:query' }
  },
  // 添加编辑企业页
  {
    path: '/exterpriseAdd/:id?',
    name: 'exterpriseAdd',
    component: () => import('@/views/park/AddEnterprise.vue'),
    meta: { hidden: true, permissionFeatures: 'park:enterprise:add_edit' }
  },
  // 查看月卡页
  {
    path: '/cardWatch/:id?',
    name: 'cardWatch',
    component: () => import('@/views/car/WatchCard.vue'),
    meta: { hidden: true, permissionFeatures: 'parking:card:query' },
  },
  // 新增月卡添加编辑页
  {
    path: '/cardAdd/:id?',
    name: 'cardAdd',
    component: () => import('@/views/car/AddCard.vue'),
    meta: { hidden: true, permissionFeatures: 'parking:card:add_edit' },
  },
]